﻿package mortal.game.resource
{
    import com.gengine.resource.*;
    import flash.utils.*;

    public class MusicsAndSoundsConfig extends Object
    {
        private var _soundsDic:Dictionary;
        private static var _instance:MusicsAndSoundsConfig;

        public function MusicsAndSoundsConfig()
        {
            this._soundsDic = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" MusicsAndSoundsConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Array = null;
            var _loc_2:* = param1["sounds"]["sound"] as Array;
            for each (_loc_3 in _loc_2)
            {
                
                this._soundsDic[_loc_3.type] = _loc_3.fileName;
            }
            _loc_4 = param1["deathSounds"]["deathSound"] as Array;
            for each (_loc_3 in _loc_4)
            {
                
                this._soundsDic[_loc_3.sex + "_" + _loc_3.career] = _loc_3.fileName;
            }
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getObjectByFileName("sound.xml");
            this.write(_loc_1);
            return;
        }// end function

        public function getSoundFileNameByType(param1:String) : String
        {
            return this._soundsDic[param1] as String;
        }// end function

        public static function get instance() : MusicsAndSoundsConfig
        {
            if (_instance == null)
            {
                _instance = new MusicsAndSoundsConfig;
            }
            return _instance;
        }// end function

    }
}
